import 'package:flutter/material.dart';

void main() => runApp(Detail());

class Detail extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: detailHomePage(),
    );
  }
}

class detailHomePage extends StatefulWidget {
  @override
  _detailHomePageState createState() => _detailHomePageState();
}

class _detailHomePageState extends State<detailHomePage>
    with SingleTickerProviderStateMixin {
  late TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: 3, vsync: this);
  }

  @override
  void dispose() {
    _tabController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    final Width = size.width;
    final Height = size.height;

    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.white,
        title: Text(
          '软件工程',
          style: TextStyle(color: Colors.grey[700]),
        ),
        leading: IconButton(
          icon: Icon(
            Icons.arrow_back,
            color: Colors.black54,
          ),
          onPressed: () {
            // 返回按钮功能
            Navigator.pop(context);
          },
        ),
      ),
      body: Stack(
        children: <Widget>[
          Column(
            children: <Widget>[
              TabBar(
                controller: _tabController,
                tabs: <Widget>[
                  Text(
                    '签到记录',
                    style: TextStyle(fontSize: 16, color: Colors.grey[700]),
                  ),
                  Text(
                    '请假申请',
                    style: TextStyle(fontSize: 16, color: Colors.grey[700]),
                  ),
                ],
              ),
              Expanded(
                child: TabBarView(
                  controller: _tabController,
                  children: <Widget>[
                    ListView(
                      children: <Widget>[
                        MaterialButton(
                          //背景颜色
                          color: Colors.blue,
                          //边框样式
                          shape: const RoundedRectangleBorder(
                            //边框圆角
                            borderRadius: BorderRadius.all(
                              Radius.circular(40),
                            ),
                          ),
                          //按钮高度
                          minWidth: 0.3 * Width,
                          height: 0.06 * Height,
                          //点击事件
                          onPressed: () {},
                          child: const Text(
                            "910238019849104",
                            style: TextStyle(fontSize: 12, color: Colors.white),
                          ),
                        ),
                      ],
                    ),
                    ListView(
                      children: <Widget>[
                        MaterialButton(
                          //背景颜色
                          color: Colors.green,
                          //边框样式
                          shape: const RoundedRectangleBorder(
                            //边框圆角
                            borderRadius: BorderRadius.all(
                              Radius.circular(40),
                            ),
                          ),
                          //按钮高度
                          minWidth: 0.3 * Width,
                          height: 0.06 * Height,
                          //点击事件
                          onPressed: () {},
                          child: const Text(
                            "idjfisdhfishf",
                            style: TextStyle(fontSize: 12, color: Colors.white),
                          ),
                        ),
                      ],
                    ),
                  ],
                ),
              ),
            ],
          ),
          Positioned(
            bottom: 0.05 * Width,
            right: 0.05 * Width,
            child: FloatingActionButton(
              onPressed: () {
                showDialog(
                    context: context,
                    barrierDismissible: true,
                    // Set to true if you want to dismiss the dialog on tap outside
                    builder: (BuildContext context) {
                      return newLeave();
                    });
              },
              child: Icon(Icons.add),
            ),
          )
        ],
      ),
    );
  }
}


class newLeave extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    final Width = size.width;
    final Height = size.height;
    return Dialog(
      child: Container(
        color: Colors.grey[100],
        padding: EdgeInsets.all(0.1 * Width),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Container(
              width: 0.82 * Width,
              height: 0.08 * Height, // 调整高度
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(8),
                boxShadow: [BoxShadow(color: Colors.grey.shade200, blurRadius: 8)],
              ),
              child: TextField(
                maxLines: null,
                maxLength: 40,
                decoration: InputDecoration(
                  hintText: '输入请假时间',
                  contentPadding: EdgeInsets.all(16.0),
                  border: InputBorder.none,
                ),
              ),
            ),
            SizedBox(height: 0.04 * Height), // 调整垂直间隙
            Container(
              width: 0.82 * Width,
              height: 0.08 * Height, // 调整高度
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(8),
                boxShadow: [BoxShadow(color: Colors.grey.shade200, blurRadius: 8)],
              ),
              child: TextField(
                maxLines: null,
                maxLength: 30,
                decoration: InputDecoration(
                  hintText: '输入请假理由',
                  contentPadding: EdgeInsets.all(16.0),
                  border: InputBorder.none,
                ),
              ),
            ),
            SizedBox(height: 0.02 * Height), // 调整垂直间隙
            Row(
              children: [
                Expanded(
                  child: MaterialButton(
                    color: Colors.white,
                    shape: const RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(
                        Radius.circular(8),
                      ),
                    ),
                    minWidth: 0.03 * Width,
                    height: 0.07 * Height,
                    onPressed: () {},
                    child: const Text(
                      "提交",
                      style: TextStyle(fontSize: 14, color: Colors.black87),
                    ),
                  ),
                ),
                SizedBox(width: 0.08 * Width),
                Expanded(
                  child: MaterialButton(
                    color: Colors.blue,
                    shape: const RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(
                        Radius.circular(8),
                      ),
                    ),
                    minWidth: 0.03 * Width,
                    height: 0.07 * Height,
                    onPressed: () {},
                    child: const Text(
                      "确认",
                      style: TextStyle(fontSize: 14, color: Colors.white),
                    ),
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}


